package ui;

import java.awt.Image;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import config.GameConfig;

public class Img {
	private Img(){}

	/**
	 * 图片路径
	 */
	public static final String GRAPHICS_PATH = "graphics/";
	
	/**
	 * 用户指定的路径
	 */
	private static final String DEFAULT_PATH = "東京食尸鬼";
	
	/**
	 *窗体边框切片 
	 */
	public static Image WINDOW = null;
	
	/**
	 * 数字切片
	 */
	public static Image NUMBER = null;
	
	/**
	 * 矩形值槽图片
	 */
	public static Image RECT = null;
	
	/**
	 * 个人签名
	 */
	public static Image SIGN = null;
	
	/**
	 * 标题切片（数据库）
	 */
	public static Image DB = null;
	
	/**
	 * 标题切片（本地记录）
	 */
	public static Image DISK = null;
	
	/**
	 * 小方块图片
	 */
	public static Image ACT = null;
	
	/**
	 * 标题切片（等级）
	 */
	public static Image LEVEL = null;
	
	/**
	 * 标题切片（分数）
	 */
	public static Image POINT = null;
	
	/**
	 * 标题切片（消行）
	 */
	public static Image RMLINE = null;

	/**
	 * 阴影
	 */
	public static Image SHADOW = null;

	/**
	 * 暂停图片
	 */
	public static Image PAUSE = null;
	
	/**
	 * 失败图片
	 */
	public static Image LOSE = null;
	
	/**
	 * 开始按钮
	 */
	public static ImageIcon BTN_START = null;
	
	/**
	 * 设置按钮
	 */
	public static ImageIcon BTN_CONFIG = null;
	
	/**
	 * 下一个方块形状
	 */
	public static Image[] NEXT_ACT = null;
	
	/**
	 * 背景
	 */
	public static List<Image> BG_LIST = null;
	
	/**
	 * 初始化图片
	 */
	static {
		setSkin(DEFAULT_PATH);
	}
	
	/**
	 * 设置皮肤
	 */
	public static void setSkin(String path) {
		String skinPath = GRAPHICS_PATH + path;
		//开始按钮
		BTN_START = new ImageIcon(skinPath + "/string/start.png");
		//设置开始按钮图标
		//设置按钮
		BTN_CONFIG = new ImageIcon(skinPath + "/string/config.png"); 
		//窗体边框切片 
		WINDOW = new ImageIcon(skinPath + "/window/Window1.png").getImage();
		// 数字切片
		NUMBER = new ImageIcon(skinPath + "/string/num.png").getImage();
		//矩形值槽图片
		RECT = new ImageIcon(skinPath + "/window/rect.png").getImage();
		//个人签名
		SIGN = new ImageIcon(skinPath + "/string/sign.png").getImage();
		// 标题切片（数据库）
		DB = new ImageIcon(skinPath + "/string/db.png").getImage();
		//标题切片（本地记录）
		DISK = new ImageIcon(skinPath + "/string/disk.png").getImage();
		// 小方块图片
		ACT = new ImageIcon(skinPath + "/game/rect.png").getImage();
		//标题切片（等级）
		LEVEL = new ImageIcon(skinPath + "/string/level.png").getImage();
		//标题切片（分数）
		POINT = new ImageIcon(skinPath + "/string/point.png").getImage();
		//标题切片（消行）
		RMLINE = new ImageIcon(skinPath + "/string/rmline.png").getImage();
		// 阴影
		SHADOW = new ImageIcon(skinPath + "/game/shadow.png").getImage();
		//暂停图片
		PAUSE = new ImageIcon(skinPath + "/string/pause.png").getImage();
		//失败图片
		LOSE = new ImageIcon(skinPath + "/string/lose.png").getImage();
		//下一个方块图片
		NEXT_ACT = new Image[GameConfig.getSystemConfig().getTypeConfig().size()];
		for (int i = 0; i < NEXT_ACT.length; i++) {
			NEXT_ACT[i] = new ImageIcon(skinPath + "/game/" + i + ".png").getImage();
		}
		//背景图片数组
		File dir = new File(skinPath + "/background");
		File[] files = dir.listFiles();
		BG_LIST = new ArrayList<Image>();
		for (File file : files) {
			if(!file.isDirectory()){
				BG_LIST.add(new ImageIcon(file.getPath()).getImage());
			}
		}
	}
}